<?php

namespace app\common\repositories\property\auth;

use app\helper\TempData;
use app\common\repositories\BaseRepository;
use app\common\dao\property\auth\PropertyAuthAccessDao;

/**
 * Class PropertyAuthAccessRepository
 *
 * @package app\common\repositories\property\auth
 * @mixin PropertyAuthAccessDao
 */
class PropertyAuthAccessRepository extends BaseRepository
{

    public function __construct(PropertyAuthAccessDao $dao)
    {
        $this->dao = $dao;
    }

    public function getPropertyIdsByUserId(int $userId, $rule = '')
    {
        return TempData::remember('property_user_all_property_id_' . $userId . $rule, function () use ($userId, $rule) {
            $propertyIds = $this->dao->getSearch([
                'user_id' => $userId
            ])->column('property_id');
            return $propertyIds;
        });
    }

}
